{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4734468f",
   "metadata": {},
   "outputs": [],
   "source": [
    "---------\n",
    "* 日期：2022-11-23 | week14 \n",
    "* 课程：Python\n",
    "* 记录人：杨静雯~\n",
    "---------\n",
    "\n",
    "# 本周学习目标\n",
    "\n",
    "1. 函数\n",
    "2. 模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6e6ff60",
   "metadata": {},
   "source": [
    "## 函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9392fc89",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user():\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello,world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c8280c9e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello,world\n"
     ]
    }
   ],
   "source": [
    "greet_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ca3fff8c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def greet_user(username):\n",
    "    \"\"\"用户问候语\"\"\"\n",
    "    print(\"hello\",username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0e7fe4b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello Max\n"
     ]
    }
   ],
   "source": [
    "greet_user(username=\"Max\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "125bf3e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数的意义\n",
    "1. 可重复使用\n",
    "2. 可以给了解python的人使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2bea3caf",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践：广州南方学院新闻网站url实践函数\n",
    "def NFU_NEWS_URL(分类,页码):\n",
    "    \"\"\"广州南方学院新闻页面url数据\n",
    "       分类只需要写对应的编码就可以，对应的页码如下：\n",
    "       分类：【学校要闻:xxyw,校园动态:xydt,通知公告:tzgg,招投标:ztb】\n",
    "       页码包含：【113,106,37,,27】\n",
    "    \"\"\"\n",
    "    \n",
    "    for i in range(页码):\n",
    "        print(\"https://www/nfu.edu.cn\"+ 分类 +\"/index\"+str(i)+\"/htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "24141821",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www/nfu.edu.cnxxyw/index0/htm\n",
      "https://www/nfu.edu.cnxxyw/index1/htm\n",
      "https://www/nfu.edu.cnxxyw/index2/htm\n",
      "https://www/nfu.edu.cnxxyw/index3/htm\n",
      "https://www/nfu.edu.cnxxyw/index4/htm\n",
      "https://www/nfu.edu.cnxxyw/index5/htm\n",
      "https://www/nfu.edu.cnxxyw/index6/htm\n",
      "https://www/nfu.edu.cnxxyw/index7/htm\n",
      "https://www/nfu.edu.cnxxyw/index8/htm\n",
      "https://www/nfu.edu.cnxxyw/index9/htm\n",
      "https://www/nfu.edu.cnxxyw/index10/htm\n",
      "https://www/nfu.edu.cnxxyw/index11/htm\n",
      "https://www/nfu.edu.cnxxyw/index12/htm\n",
      "https://www/nfu.edu.cnxxyw/index13/htm\n",
      "https://www/nfu.edu.cnxxyw/index14/htm\n",
      "https://www/nfu.edu.cnxxyw/index15/htm\n",
      "https://www/nfu.edu.cnxxyw/index16/htm\n",
      "https://www/nfu.edu.cnxxyw/index17/htm\n",
      "https://www/nfu.edu.cnxxyw/index18/htm\n",
      "https://www/nfu.edu.cnxxyw/index19/htm\n",
      "https://www/nfu.edu.cnxxyw/index20/htm\n",
      "https://www/nfu.edu.cnxxyw/index21/htm\n",
      "https://www/nfu.edu.cnxxyw/index22/htm\n",
      "https://www/nfu.edu.cnxxyw/index23/htm\n",
      "https://www/nfu.edu.cnxxyw/index24/htm\n",
      "https://www/nfu.edu.cnxxyw/index25/htm\n",
      "https://www/nfu.edu.cnxxyw/index26/htm\n",
      "https://www/nfu.edu.cnxxyw/index27/htm\n",
      "https://www/nfu.edu.cnxxyw/index28/htm\n",
      "https://www/nfu.edu.cnxxyw/index29/htm\n",
      "https://www/nfu.edu.cnxxyw/index30/htm\n",
      "https://www/nfu.edu.cnxxyw/index31/htm\n",
      "https://www/nfu.edu.cnxxyw/index32/htm\n",
      "https://www/nfu.edu.cnxxyw/index33/htm\n",
      "https://www/nfu.edu.cnxxyw/index34/htm\n",
      "https://www/nfu.edu.cnxxyw/index35/htm\n",
      "https://www/nfu.edu.cnxxyw/index36/htm\n",
      "https://www/nfu.edu.cnxxyw/index37/htm\n",
      "https://www/nfu.edu.cnxxyw/index38/htm\n",
      "https://www/nfu.edu.cnxxyw/index39/htm\n",
      "https://www/nfu.edu.cnxxyw/index40/htm\n",
      "https://www/nfu.edu.cnxxyw/index41/htm\n",
      "https://www/nfu.edu.cnxxyw/index42/htm\n",
      "https://www/nfu.edu.cnxxyw/index43/htm\n",
      "https://www/nfu.edu.cnxxyw/index44/htm\n",
      "https://www/nfu.edu.cnxxyw/index45/htm\n",
      "https://www/nfu.edu.cnxxyw/index46/htm\n",
      "https://www/nfu.edu.cnxxyw/index47/htm\n",
      "https://www/nfu.edu.cnxxyw/index48/htm\n",
      "https://www/nfu.edu.cnxxyw/index49/htm\n",
      "https://www/nfu.edu.cnxxyw/index50/htm\n",
      "https://www/nfu.edu.cnxxyw/index51/htm\n",
      "https://www/nfu.edu.cnxxyw/index52/htm\n",
      "https://www/nfu.edu.cnxxyw/index53/htm\n",
      "https://www/nfu.edu.cnxxyw/index54/htm\n",
      "https://www/nfu.edu.cnxxyw/index55/htm\n",
      "https://www/nfu.edu.cnxxyw/index56/htm\n",
      "https://www/nfu.edu.cnxxyw/index57/htm\n",
      "https://www/nfu.edu.cnxxyw/index58/htm\n",
      "https://www/nfu.edu.cnxxyw/index59/htm\n",
      "https://www/nfu.edu.cnxxyw/index60/htm\n",
      "https://www/nfu.edu.cnxxyw/index61/htm\n",
      "https://www/nfu.edu.cnxxyw/index62/htm\n",
      "https://www/nfu.edu.cnxxyw/index63/htm\n",
      "https://www/nfu.edu.cnxxyw/index64/htm\n",
      "https://www/nfu.edu.cnxxyw/index65/htm\n",
      "https://www/nfu.edu.cnxxyw/index66/htm\n",
      "https://www/nfu.edu.cnxxyw/index67/htm\n",
      "https://www/nfu.edu.cnxxyw/index68/htm\n",
      "https://www/nfu.edu.cnxxyw/index69/htm\n",
      "https://www/nfu.edu.cnxxyw/index70/htm\n",
      "https://www/nfu.edu.cnxxyw/index71/htm\n",
      "https://www/nfu.edu.cnxxyw/index72/htm\n",
      "https://www/nfu.edu.cnxxyw/index73/htm\n",
      "https://www/nfu.edu.cnxxyw/index74/htm\n",
      "https://www/nfu.edu.cnxxyw/index75/htm\n",
      "https://www/nfu.edu.cnxxyw/index76/htm\n",
      "https://www/nfu.edu.cnxxyw/index77/htm\n",
      "https://www/nfu.edu.cnxxyw/index78/htm\n",
      "https://www/nfu.edu.cnxxyw/index79/htm\n",
      "https://www/nfu.edu.cnxxyw/index80/htm\n",
      "https://www/nfu.edu.cnxxyw/index81/htm\n",
      "https://www/nfu.edu.cnxxyw/index82/htm\n",
      "https://www/nfu.edu.cnxxyw/index83/htm\n",
      "https://www/nfu.edu.cnxxyw/index84/htm\n",
      "https://www/nfu.edu.cnxxyw/index85/htm\n",
      "https://www/nfu.edu.cnxxyw/index86/htm\n",
      "https://www/nfu.edu.cnxxyw/index87/htm\n",
      "https://www/nfu.edu.cnxxyw/index88/htm\n",
      "https://www/nfu.edu.cnxxyw/index89/htm\n",
      "https://www/nfu.edu.cnxxyw/index90/htm\n",
      "https://www/nfu.edu.cnxxyw/index91/htm\n",
      "https://www/nfu.edu.cnxxyw/index92/htm\n",
      "https://www/nfu.edu.cnxxyw/index93/htm\n",
      "https://www/nfu.edu.cnxxyw/index94/htm\n",
      "https://www/nfu.edu.cnxxyw/index95/htm\n",
      "https://www/nfu.edu.cnxxyw/index96/htm\n",
      "https://www/nfu.edu.cnxxyw/index97/htm\n",
      "https://www/nfu.edu.cnxxyw/index98/htm\n",
      "https://www/nfu.edu.cnxxyw/index99/htm\n",
      "https://www/nfu.edu.cnxxyw/index100/htm\n",
      "https://www/nfu.edu.cnxxyw/index101/htm\n",
      "https://www/nfu.edu.cnxxyw/index102/htm\n",
      "https://www/nfu.edu.cnxxyw/index103/htm\n",
      "https://www/nfu.edu.cnxxyw/index104/htm\n",
      "https://www/nfu.edu.cnxxyw/index105/htm\n",
      "https://www/nfu.edu.cnxxyw/index106/htm\n",
      "https://www/nfu.edu.cnxxyw/index107/htm\n",
      "https://www/nfu.edu.cnxxyw/index108/htm\n",
      "https://www/nfu.edu.cnxxyw/index109/htm\n",
      "https://www/nfu.edu.cnxxyw/index110/htm\n",
      "https://www/nfu.edu.cnxxyw/index111/htm\n",
      "https://www/nfu.edu.cnxxyw/index112/htm\n"
     ]
    }
   ],
   "source": [
    "NFU_NEWS_URL(\"xxyw\",113)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "47d05bcb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function NFU_NEWS_URL in module __main__:\n",
      "\n",
      "NFU_NEWS_URL(分类, 页码)\n",
      "    广州南方学院新闻页面url数据\n",
      "    分类只需要写对应的编码就可以，对应的页码如下：\n",
      "    分类：【学校要闻:xxyw,校园动态:xydt,通知公告:tzgg,招投标:ztb】\n",
      "    页码包含：【113,106,37,,27】\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cf06f5a2",
   "metadata": {},
   "source": [
    "## 模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2d785525",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'colloge_url_crawl'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [19]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mcolloge_url_crawl\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'colloge_url_crawl'"
     ]
    }
   ],
   "source": [
    "import colloge_url_crawl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "8eb7c3ab",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'colloge_url_crawl' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [20]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m help(\u001b[43mcolloge_url_crawl\u001b[49m\u001b[38;5;241m.\u001b[39mNFU_NEWS_URL)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'colloge_url_crawl' is not defined"
     ]
    }
   ],
   "source": [
    "help(colloge_url_crawl.NFU_NEWS_URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a29358d0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
